[AspNetCore] Update gRPC Semantic Conventions#4370
Open
martincostello wants to merge 9 commits into
Open
Conversation
Add optimizations, recommended by Copilot, to reduce allocations in `HttpInListener.OnStopActivity()`: - Cache activity display names. - Uses slices instead of `Regex`. - Avoid enum reflection. - Null check delegates to avoid try-catch blocks. - Use SetCustomProperty to check for who made the instrumentation. - Avoid running gRPC-related code for HTTP 1.1. - Avoid additional check for the normalized HTTP method. - Use pattern matching on nullable.
Update the Semantic Conventions version for RPC Server spans to v1.41.0.
Also remove `grpc.status` and `grpc.target`.
Move RpcSemanticConventionHelper to shared code for re-use.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates ASP.NET Core gRPC server-span attribute emission to support newer RPC/gRPC semantic conventions (v1.41.0) behind the OTEL_SEMCONV_STABILITY_OPT_IN opt-in mechanism, while preserving the existing default behavior.
Changes:
- Introduces
RpcSemanticConventionHelperto parseOTEL_SEMCONV_STABILITY_OPT_INand select old/new/dual RPC attribute emission. - Updates ASP.NET Core gRPC server span tagging to optionally emit v1.41.0-style RPC attributes and remove additional gRPC framework tags.
- Updates docs/changelog/solution/project wiring to include the new helper and reference updated spec links.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/RpcSemanticConventionHelper.cs | Adds opt-in parsing for RPC semantic convention emission modes (rpc, rpc/dup). |
| src/Shared/GrpcTagHelper.cs | Adds additional gRPC tag constants and updates spec link references. |
| src/OpenTelemetry.Instrumentation.AspNetCore/README.md | Updates the semantic conventions documentation link target. |
| src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj | Links in the new shared RPC semantic convention helper file. |
| src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs | Gates gRPC server-span tag emission between old/new conventions and removes more framework-provided gRPC tags. |
| src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | Documents the new opt-in behavior for RPC/gRPC semconv v1.41.0. |
| src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs | Adds options derived from OTEL_SEMCONV_STABILITY_OPT_IN to control old/new RPC tag emission. |
| opentelemetry-dotnet-contrib.slnx | Adds the new shared helper file to the solution. |
Comments suppressed due to low confidence (1)
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs:456
- When emitting the new RPC semantic conventions,
rpc.serviceis intentionally omitted, butrpc.methodis still set to only the method name (details.RpcMethod). This loses the service portion and doesn’t align with the v1.40+ guidance thatrpc.methodshould be the fully-qualified logical method name. Consider settingrpc.methodto the fully-qualified value (e.g., the same value used foractivity.DisplayName) whenemitNewRpcAttributesis enabled.
activity.SetTag(SemanticConventions.AttributeRpcMethod, details.RpcMethod);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use correct properties to populate `network.peer.address` and `network.peer.port`.
The GitHub UI didn't actually apply the changes I made to fix it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Update the Semantic Conventions version for gRPC Server spans to v1.41.0.
One thing I'm unsure of is whether or not we need to implement
OTEL_SEMCONV_STABILITY_OPT_INor not given that the support is already experimental.Once that question is answered I'll add/update the tests as appropriate.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)